﻿using Adnc.WebApi.Shared;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WYT.Sys.Application.Contracts.Dtos.Aliyun;
using WYT.Sys.Application.Contracts.Dtos.Common;
using WYT.Sys.Application.Contracts.Services;

namespace WYT.Sys.WebApi.Controllers
{
    /// <summary>
    /// 阿里云服务
    /// </summary>
    [Route("sys/[Controller]")]
    [ApiController]
    public class AliyunController : AdncControllerBase
    {
        private readonly IAliyunAppService _aliyunAppService;

        public AliyunController(IAliyunAppService aliyunAppService)
        {
            _aliyunAppService = aliyunAppService;
        }

        /// <summary>
        /// 发送短信消息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("_sendSms")]
        [AllowAnonymous]
        public async Task<ActionResult<bool>> SendSms(SendSmsDto input)
        {
            return Result(await _aliyunAppService.SendSms(input));
        }

        /// <summary>
        /// 获取Oss文件上传签名
        /// </summary>
        /// <param name="dir"></param>
        /// <returns></returns>
        [HttpGet("OssSign")]
        public  WYTActionResult<OssSignDto> GetOssSign([FromQuery]string dir)
        {
            return Success(_aliyunAppService.GetOssSign(dir));
        }
    }
}
